package com.adtec.base.cloud.comminicate.communicate.config.handler;

import com.adtec.base.cloud.commons.exception.AjaxResponse;
import com.adtec.base.cloud.commons.exception.CustomExceptionType;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * sentinel 限流示例
 */

@Slf4j
public class CommonlyusedControllerHandler {

    public static AjaxResponse pwdresetBlockHandler(@RequestParam Integer userId,
                                                    BlockException blockException) {
        log.info("请稍后再试");
        return AjaxResponse.error(CustomExceptionType.SYSTEM_ERROR,
                "尊敬的客户您好，系统服务繁忙，请稍后再试!");
    }

    public static AjaxResponse pwdresetFallback(@RequestParam Integer userId, Throwable e) {
        log.info("pwdresetFallBack");

        return AjaxResponse.error(CustomExceptionType.SYSTEM_ERROR,
                "尊敬的客户您好，系统服务繁忙，请稍后再试!（pwdresetFallBack）");
    }

    public static AjaxResponse defaultFallback(Throwable e) {
        return AjaxResponse.error(CustomExceptionType.SYSTEM_ERROR, e.getMessage());
    }


}